package cn.com.nes.site.controller.workOrder;

import cn.com.nes.common.util.ExcelUtils;
import cn.com.nes.common.web.CommonResult;
import cn.com.nes.site.entity.PageData;
import cn.com.nes.site.entity.bo.workorder.GetTeamWorkOrderInstallPageBO;
import cn.com.nes.site.entity.bo.workorder.WorkOrderBO;
import cn.com.nes.site.entity.dto.workOrder.*;
import cn.com.nes.site.entity.em.CompanyTypeEnum;
import cn.com.nes.site.entity.vo.NullVO;
import cn.com.nes.site.entity.vo.project.WorkOrderReviewVo;
import cn.com.nes.site.entity.vo.workOrder.*;
import cn.com.nes.site.handle.SendMessageHandler;
import cn.com.nes.site.service.system.company.BusinessCompanyService;
import cn.com.nes.site.service.system.user.SystemUserService;
import cn.com.nes.site.service.workOrder.AsyncDistributeWorkOrderInstallService;
import cn.com.nes.site.service.workOrder.WorkOrderRejectionInfoService;
import cn.com.nes.site.service.workOrder.WorkOrderService;
import cn.com.nes.site.service.workOrder.bo.CancelWorkOrdersBO;
import cn.com.nes.site.service.workOrder.bo.CancelWorkOrdersByAreaCodeBO;
import cn.com.nes.site.service.workOrder.bo.CaptainCancelWorkOrdersBO;
import cn.com.nes.site.service.workOrder.bo.GetWorkOrderRejectionInfoBO;
import cn.com.nes.site.service.workOrder.dto.GetWorkOrderInstallPageDTO;
import cn.com.nes.site.service.workOrder.dto.WorkOrderRejectionInfoDTO;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 工单接口层
 */
@Api(tags = {"项目模块 - 安装工单管理"})
@Controller
@RequestMapping("/v2/order/work")
@EnableAsync
@Slf4j
public class WorkOrderController {

    @Resource
    private WorkOrderService workOrderService;

    @Resource
    private SystemUserService systemUserService;

    @Resource
    private BusinessCompanyService businessCompanyService;
    @Resource
    private AsyncDistributeWorkOrderInstallService asyncDistributeWorkOrderInstallService;

    @Resource
    private WorkOrderRejectionInfoService workOrderRejectionInfoService;

    @Resource
    private SendMessageHandler sendMessageHandler;

    /**
     * 查询长效管护安装人员列表,下拉框不分页 - 【姓名 + id】
     */
    @Deprecated
    @RequestMapping(value = "/getInstallPersonList", method = RequestMethod.GET)
    @ResponseBody
    public PageData getInstallPersonList(NullVO vo) throws Exception {
        return PageData.ok("installPersonList", systemUserService.getInstallPersonList(vo));
    }

    @ApiOperation("单条派发安装工单")
    @RequestMapping(value = "/distributeWorkOrderInstall", method = RequestMethod.POST)
    @ResponseBody
    public PageData distributeWorkOrderInstall(@RequestBody @Validated DistributeWorkOrderInstallVO vo) throws Exception {
        String workOrderId = workOrderService.distributeWorkOrderInstall(vo.convertToBo());

        // 工单派发成功后给接单人发送通知
        try {
            Map<String, String> sendParams = new HashMap<>();
            sendParams.put("workOrderType", "install");
            sendParams.put("workOrderId", workOrderId);
            sendParams.put("companyId", vo.getOperateUserCompanyId());
            sendMessageHandler.sendWorkOrderMessageToEasyRepair(systemUserService.getUserPhoneById(vo.getMaintainId()), sendParams);
        } catch (Exception e) {
            log.error("派单后发送通知消息失败,失败原因:{}", e.getMessage());
            e.printStackTrace();
        }

        // 返回工单id
        return PageData.ok("workOrderId", workOrderId);
    }

    @ApiOperation("批量派发安装工单")
    @RequestMapping(value = "/batchDistributeWorkOrderInstall", method = RequestMethod.POST)
    @ResponseBody
    public PageData batchDistributeWorkOrderInstall(@RequestBody @Validated BatchDistributeWorkOrderInstallVO vo) throws Exception {
        return PageData.ok(asyncDistributeWorkOrderInstallService.asyncDistributeWorkOrderInstall(vo));
    }

    @ApiOperation("查询易修工单列表(全部公司)")
    @RequestMapping(value = "/getAllWorkOrderPage", method = RequestMethod.GET)
    @ResponseBody
    public PageData getAllWorkOrderPage(GetAllWorkOrderPageVO vo) throws Exception {
        return workOrderService.getAllWorkOrderPage(vo);
    }

    @ApiOperation("查询安装工单分页 - 热链云PC端")
    @RequestMapping(value = "/getWorkOrderInstallPage", method = RequestMethod.GET)
    @ResponseBody
    public PageData getWorkOrderInstallPage(GetWorkOrderInstallPageVO vo) throws Exception {
        // 登录用户公司类型不等于 00（创今），公司ID设置为当前登录公司ID
        if (!CompanyTypeEnum._00.getKey().equals(vo.getOperateUserCompanyType()))
            vo.setCompanyId(vo.getOperateUserCompanyId());
        return workOrderService.getWorkOrderInstallPage(vo);
    }

    @ApiOperation("查询安装工单详情")
    @RequestMapping(value = "/getWorkOrderInstallDetail", method = RequestMethod.GET)
    @ResponseBody
    public PageData getWorkOrderInstallDetail(@Validated GetWorkOrderInstallDetailVO vo) throws Exception {
        return workOrderService.getWorkOrderInstallDetail(vo);
    }

    @ApiOperation("查询安装工单时间轴 - 操作记录列表(不分页)")
    @RequestMapping(value = "/getWorkOrderInstallTimeAxis", method = RequestMethod.GET)
    @ResponseBody
    public PageData getWorkOrderInstallTimeAxis(@Validated GetWorkOrderInstallDetailVO vo) throws Exception {
        return workOrderService.getWorkOrderInstallTimeAxis(vo);
    }

    @ApiOperation("约定上门时间")
    @RequestMapping(value = "/updateDoorTime", method = RequestMethod.POST)
    @ResponseBody
    public PageData updateDoorTime(@RequestBody @Validated UpdateDoorTimeVo vo) {
        return workOrderService.updateDoorTime(vo);
    }

    @ApiOperation("安装和维修工单接单")
    @RequestMapping(value = "/acceptOrderInstall", method = RequestMethod.POST)
    @ResponseBody
    public PageData acceptOrderInstall(@RequestBody @Validated AcceptOrderInstallVo vo) throws Exception {
        return workOrderService.acceptOrderInstall(vo);
    }

    @ApiOperation("安装和维修工单签到打卡")
    @RequestMapping(value = "/punchClockOrderInstall", method = RequestMethod.POST)
    @ResponseBody
    public PageData punchClockOrderInstall(@RequestBody @Validated AcceptOrderInstallVo vo) throws Exception {
        return workOrderService.punchClockOrderInstall(vo);
    }

    @ApiOperation("安装和维修工单工单拒单")
    @RequestMapping(value = "/rejectionOrderInstall", method = RequestMethod.POST)
    @ResponseBody
    public PageData rejectionOrderInstall(@RequestBody @Validated RejectionOrderInstallVo vo) throws Exception {
        return workOrderService.rejectionOrderInstall(vo);
    }

    @ApiOperation("安装和维修工单转单")
    @RequestMapping(value = "/transferOrderInstall", method = RequestMethod.POST)
    @ResponseBody
    public PageData transferOrderInstall(@RequestBody @Validated TransferOrderInstallVo vo) throws Exception {
        PageData pageData = workOrderService.transferOrderInstall(vo);
        if (vo.getTransferOrder()) {
            // 给接单人发送新工单通知
            try {
                String body = "您的队友给您转发了新的工单，点击查看详情。";

                Map<String, String> sendParams = new HashMap<>();
                sendParams.put("workOrderType", "install");
                sendParams.put("workOrderId", String.valueOf(vo.getOrderId()));
                sendParams.put("companyId", vo.getOperateUserCompanyId());
                sendMessageHandler.sendWorkOrderMessageToEasyRepair(null, body, Collections.singletonList(vo.getInstallUserInfo().getPhone()), sendParams);
            } catch (Exception e) {
                log.error("转单后发送通知消息失败,失败原因:{}", e.getMessage());
                e.printStackTrace();
            }
        }
        return pageData;
    }

    @ApiOperation("安装工单补充房屋信息")
    @RequestMapping(value = "/replenishHouseInfo", method = RequestMethod.POST)
    @ResponseBody
    public PageData replenishHouseInfo(@RequestBody @Validated ReplenishHouseInfoVO vo) throws Exception {
        return workOrderService.replenishHouseInfo(vo);
    }

    @ApiOperation("安装工单补充房屋信息相关下拉框")
    @RequestMapping(value = "/replenishHouseDropdownBox", method = RequestMethod.GET)
    @ResponseBody
    public PageData replenishHouseDropdownBox(NullVO vo) throws Exception {
        return workOrderService.replenishHouseDropdownBox(vo);
    }

    @ApiOperation("查询当前工单可更换的设备列表 - 下拉框,不分页")
    @RequestMapping(value = "/getGoodsList", method = RequestMethod.GET)
    @ResponseBody
    public PageData getGoodsList(QueryGoodsListByWorkOrderVO vo) throws Exception {
        return workOrderService.getGoodsList(vo);
    }

    @Deprecated // 易修没调用这个接口
    @ApiOperation("安装工单修改设备信息")
    @RequestMapping(value = "/updatePriceDetail", method = RequestMethod.POST)
    @ResponseBody
    public PageData updatePriceDetail(@RequestBody @Validated UpdatePriceDetailVO vo) throws Exception {
        return workOrderService.updatePriceDetail(vo);
    }

    @ApiOperation("安装工单修改设备dtu")
    @RequestMapping(value = "/updateInstallEquipment", method = RequestMethod.POST)
    @ResponseBody
    public PageData updateInstallEquipment(@RequestBody @Validated UpdateInstallEquipmentVO vo) throws Exception {
        workOrderService.updateInstallEquipment(vo);
        return PageData.ok();
    }

    @ApiOperation("安装工单提交图片信息")
    @RequestMapping(value = "/updatePicInfo", method = RequestMethod.POST)
    public @ResponseBody PageData updatePicInfo(@RequestBody @Validated UpdatePicInfoVO vo) throws Exception {
        return workOrderService.updatePicInfo(vo);
    }

    @ApiOperation("完成安装工单")
    @RequestMapping(value = "/completeOrderInstall", method = RequestMethod.POST)
    @ResponseBody
    public PageData completeOrderInstall(@RequestBody @Validated CompleteOrderInstallVo vo) throws Exception {
        return workOrderService.completeOrderInstall(vo);
    }

    @ApiOperation("查询安装信息相关下拉框")
    @RequestMapping(value = "/getInstallInfoDropdownBox", method = RequestMethod.GET)
    @ResponseBody
    public PageData getInstallInfoDropdownBox(NullVO vo) throws Exception {
        return workOrderService.getInstallInfoDropdownBox(vo);
    }

    @ApiOperation("紧急程度下拉框")
    @RequestMapping(value = "/getEmergencyDegreeDropdownBox", method = RequestMethod.GET)
    @ResponseBody
    public PageData getEmergencyDegreeDropdownBox(NullVO vo) throws Exception {
        return workOrderService.getEmergencyDegreeDropdownBox(vo);
    }

    @ApiOperation("工头查询施工队安装工单")
    @RequestMapping(value = "/getMyTeamWorkOrderInstallPage", method = RequestMethod.GET)
    @ResponseBody
    public PageData getMyTeamWorkOrderInstallPage(GetTeamWorkOrderInstallPageVO vo) throws Exception {
        GetTeamWorkOrderInstallPageBO bo = vo.convertToBo();
        Page<GetWorkOrderInstallPageDTO> page = workOrderService.getMyTeamWorkOrderInstallPage(bo);
        return PageData.ok(page, page.getRecords());
    }

    @ApiOperation("分单")
    @RequestMapping(value = "/distributeWorkOrder", method = RequestMethod.POST)
    public @ResponseBody PageData distributeWorkOrder(@RequestBody EasyRepairDistributeWorkOrderVO vo) throws Exception {
        return workOrderService.distributeWorkOrder(vo);
    }

    @ApiOperation("按行政区划分单")
    @RequestMapping(value = "/distributeWorkOrderByAreaCode", method = RequestMethod.POST)
    public @ResponseBody PageData distributeWorkOrderByAreaCode(@RequestBody @Validated EasyRepairDistributeWorkOrderByAreaCodeVO vo) throws Exception {
        workOrderService.distributeWorkOrderByAreaCode(vo);
        return PageData.ok();
    }

    @ApiOperation(value = "审核功能", notes = "审核功能，可批量审核")
    @RequestMapping(value = "/workOrderReview", method = RequestMethod.POST)
    public @ResponseBody PageData workOrderReview(
            @RequestBody @Validated WorkOrderReviewVo vo) throws Exception {
        return workOrderService.workOrderReview(vo);
    }

    @ApiOperation(value = "批量撤销工单")
    @RequestMapping(value = "/cancelWorkOrders", method = RequestMethod.POST)
    public @ResponseBody CommonResult<?> cancelWorkOrders(@RequestBody @Validated CancelWorkOrdersVO vo) throws Exception {
        workOrderService.cancelWorkOrders(vo.convertToBo(new CancelWorkOrdersBO()));
        return CommonResult.ok();
    }

    @ApiOperation(value = "按行政区划批量撤销工单")
    @RequestMapping(value = "/cancelWorkOrdersByAreaCode", method = RequestMethod.POST)
    public @ResponseBody CommonResult<?> cancelWorkOrdersByAreaCode(@RequestBody @Validated CancelWorkOrdersByAreaCodeVO vo) throws Exception {
        workOrderService.cancelWorkOrdersByAreaCode(vo.convertToBo(new CancelWorkOrdersByAreaCodeBO()));
        return CommonResult.ok();
    }

    @ApiOperation(value = "施工队长撤销安装工单")
    @RequestMapping(value = "/captainCancelWorkOrders", method = RequestMethod.POST)
    public @ResponseBody CommonResult<?> captainCancelWorkOrders(@RequestBody @Validated CaptainCancelWorkOrdersVO vo) throws Exception {
        workOrderService.captainCancelWorkOrders(vo.convertToBo(CaptainCancelWorkOrdersBO.class));
        return CommonResult.ok();
    }

    @ApiOperation(value = "查询工单拒单记录")
    @RequestMapping(value = "/getWorkOrderRejectionInfoPage", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<WorkOrderRejectionInfoDTO> getWorkOrderRejectionInfoPage(GetWorkOrderRejectionInfoVO vo) throws Exception {
        return CommonResult.page(workOrderRejectionInfoService.getWorkOrderRejectionInfoPage(vo.convertToBo(new GetWorkOrderRejectionInfoBO())));
    }

    @ApiOperation(value = "保存工单")
    @RequestMapping(value = "/saveWorkOrder", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<WorkOrderRejectionInfoDTO> saveWorkOrder(@RequestBody @Validated WorkOrderVO vo) throws Exception {
        return CommonResult.ok(workOrderService.saveWorkOrder(vo.convertToBo(new WorkOrderBO())));
    }

    @ApiOperation(value = "查询已安装的用户设备列表")
    @RequestMapping(value = "/queryCustomerEquipmentList", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<SaveWorkOrderByQueryDto> queryCustomerEquipmentList(@RequestBody @Validated SaveWorkOrderQueryVo vo) throws Exception {
        //已有查询代理商逻辑
        return CommonResult.page(workOrderService.queryCustomerEquipmentList(vo));
    }

    @ApiOperation(value = "根据id查询设备详情")
    @RequestMapping(value = "/getDevice", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<GetDeviceDto> getDevice(@RequestBody @Validated GetDevice vo) throws Exception {
        return CommonResult.data(workOrderService.getDevice(vo));
    }

    @ApiOperation(value = "查询维修和咨询工单列表")
    @RequestMapping(value = "/getRepairWorkOrderPage", method = RequestMethod.POST)
    @ResponseBody
    public PageData getRepairWorkOrderPage(@RequestBody GetWorkOrderRepairPageVO vo) throws Exception {
        return workOrderService.getRepairWorkOrderPage(vo);
    }

    @ApiOperation(value = "查询维修和咨询工单详情")
    @RequestMapping(value = "/getWorkOrderRepairDetail", method = RequestMethod.GET)
    @ResponseBody
    public PageData getWorkOrderRepairDetail(@Validated GetWorkOrderRepairDetailVO vo) throws Exception {
        //已有查询代理商逻辑
        return workOrderService.getWorkOrderRepairDetail(vo);
    }

    @ApiOperation(value = "完成维修工单")
    @RequestMapping(value = "/completeOrderRepair", method = RequestMethod.POST)
    @ResponseBody
    public PageData completeOrderRepair(@RequestBody CompleteOrderRepairVo vo) throws Exception {
        //已有查询代理商逻辑
        return workOrderService.completeOrderRepair(vo);
    }

    @ApiOperation(value = "查询备件类型")
    @RequestMapping(value = "/getSparePart", method = RequestMethod.POST)
    @ResponseBody
    public PageData getSparePart(GetSparePartVo vo) throws Exception {
        //已有查询代理商逻辑
        return workOrderService.getSparePart(vo.getOperateUserCompanyId());
    }

    @ApiOperation(value = "查询字典")
    @RequestMapping(value = "/getParamsByTypeValue", method = RequestMethod.POST)
    @ResponseBody
    public PageData getParamsByTypeValue(@RequestBody ParamsVo vo) throws Exception {
        //已有查询代理商逻辑
        return workOrderService.getParamsByTypeValue(vo);
    }

    @ApiOperation(value = "指定工单问题分类细类")
    @RequestMapping(value = "/evaluationWorkOrder", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<?> evaluationWorkOrder(@RequestBody @Validated EvaluationWorkOrderVo vo) {
        return workOrderService.evaluationWorkOrder(vo);
    }

    @ApiOperation(value = "修改工单状态修改指派人")
    @RequestMapping(value = "/workOrderStatus", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<?> updateWorkOrderStatus(@RequestBody @Validated WorkOrderStatusVo vo) throws Exception {
        vo.setCreateUserId(vo.getOperateUserId());
        String xzqhdms = vo.getUserInfo().getAreacode();
        return workOrderService.updateWorkOrderStatus(vo, xzqhdms);
    }

    @ApiOperation(value = "取消工单")
    @RequestMapping(value = "/closeWorkOrder", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<?> closeWorkOrder(@RequestBody CloseWorkOrderVo vo) {
        //取消、删除工单
        return workOrderService.closeWorkOrder(vo);
    }

    @ApiOperation(value = "查询已创建客服中心的公司")
    @RequestMapping(value = "/queryCompany", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<?> queryCompany(QueryCompanyVO vo) {
        //查询已创建了客服中心的公司,后期需要增加公司之间关联的功能
        return CommonResult.page(businessCompanyService.getCompanys(vo));
    }

    @ApiOperation(value = "审核维修工单")
    @RequestMapping(value = "/auditWorkOrder", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<?> auditWorkOrder(@RequestBody AuditWorkOrderVo vo) {
        vo.setUserId(vo.getUserInfo().getCallCenterUserId());
        vo.setCompanyId(Long.parseLong(vo.getOperateUserCallCenterCompanyId()));
        int res = workOrderService.auditWorkOrder(vo);
        if (res == 0) {
            return CommonResult.error("处理失败");
        }
        return CommonResult.ok("审核成功");
    }

    @ApiOperation(value = "维修工单回访")
    @RequestMapping(value = "/workOrderVisit", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<?> workOrderVisit(@RequestBody @Validated WorkOrderVisitVo vo) {
        vo.setUserId(vo.getUserInfo().getCallCenterUserId());
        //工单回访
        Long code = workOrderService.workOrderVisit(vo);
        if (ObjectUtil.isNotNull(code)) {
            return CommonResult.ok("回访成功");
        } else {
            return CommonResult.error("回访失败");
        }
    }

    @ApiOperation(value = "查看字典值树结构")
    @RequestMapping(value = "/getDictionaryTreeValue", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<?> getDictionaryTreeValue() {
        List<ParamTypeDto> dictionaryDtoList = workOrderService.getDictionaryTreeValue();
        //对其进行判断
        if (dictionaryDtoList.size() > 0) {
            //设置返回值
            return CommonResult.data(dictionaryDtoList);
        } else {
            //失败返回到信息
            return CommonResult.error("查询类型失败");
        }
    }

    @ApiOperation(value = "导出工单excle")
    @RequestMapping(value = "/exportWorkOrderInfo", method = RequestMethod.POST)
    public CommonResult<?> exportWorkOrderInfo(@RequestBody @Validated WorkOrderListVo vo, HttpServletResponse response) throws Exception {
        List<WorkOrderListExportDto> pageInfo = workOrderService.exportWorkOrderInfo(vo);
        String[] titleList = new String[]{ "联系人地址", "工单ID", "联系人", "联系电话", "厂家名称", "维修人员", "故障描述", "创建人", "创建时间", "安装时间", "接单时间", "结单时间", "上门时间",
                "状态", "审核状态", "保修状态", "故障分类", "故障细类", "故障现象", "满意度", "回访描述", "处理方式", "服务系类", "催单次数"};
        String[] fieldList = new String[]{ "installAddress", "workerOrderId", "contact", "contactTelephone", "cjmc", "wxry", "gzms", "createUserName", "formattedCreateDate", "formattedAzrqDate", "takingTime", "finishTime", "doorTime",
                "workOrderStateName", "audited", "warrantyState", "gzflmc", "gzflmxmc", "gzxxmc", "visitEval", "desc", "handleTypeName", "evaluationName", "remindOrderCount"};
        String[] typeList = new String[]{"String", "String", "String", "String", "String", "String", "String", "String", "date", "date", "date", "date", "date",
                "String", "String", "String", "String", "String", "String", "String", "String", "String", "String", "String"};
        ExcelUtils.exportData(fieldList, titleList, typeList, pageInfo, "工单列表", response, "工单统计", false);
        return null;
    }
    @ApiOperation(value = "绑定企业")
    @RequestMapping(value = "/bindCompany", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<?> bindCompany(@RequestBody @Validated BindCompanyVo vo) {
        int res = workOrderService.bindCompany(vo);
        //对其进行判断
        if (res > 0) {
            //设置返回值
            return CommonResult.ok("绑定成功");
        } else {
            //失败返回到信息
            return CommonResult.error("绑定失败");
        }
    }

    @ApiOperation(value = "查询绑定企业列表")
    @RequestMapping(value = "/queryBindCompany", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<QueryBindCompanyDto> queryBindCompany(@RequestBody @Validated QueryBindCompanyVo vo) throws Exception {
        Page<QueryBindCompanyDto> page = workOrderService.queryBindCompany(vo);
        return CommonResult.page(page);
    }
    @ApiOperation(value = "解绑绑定企业")
    @RequestMapping(value = "/unBindCompany", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<?> unBindCompany(@RequestBody @Validated DeleteBindCompanyVo vo) {
        if ( workOrderService.unBindCompany(vo)>0) {
            //设置返回值
            return CommonResult.ok("解绑成功");
        } else {
            //失败返回到信息
            return CommonResult.error("解绑失败");
        }
    }
    @ApiOperation(value = "查询代理商列表")
    @RequestMapping(value = "/getCommissionAgent", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<?>  getCommissionAgent(@RequestBody @Validated GetCommissionAgentVo vo){
       return CommonResult.page(workOrderService.getCommissionAgent(vo));
    }
}